﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Poco;
using Metier;

namespace WebApp
{
    public class ServerModelView
    {
        //
        // GET: /ServerModelView/

        public List<Table> Tables { get; set; }
        public List<Notification> Notifications { get; set; }
        public int NBNotifs { get; set; }
        public string mail { get; set; }
        GestionNotification listener;

        public int NBNotif
        {
            get { return getNbNotif(this.mail); }
        }

        public ServerModelView(string mail)
        {
            Tables = new List<Table>();
            Notifications = new List<Notification>();
            listener = new GestionNotification();
            this.mail = mail;
        }

        public List<Notification> getNotificationByType(List<Notification> list, string type)
        {
            List<Notification> mylist = new List<Notification>();
            if (list != null)
            {
                foreach (Notification item in list)
                {
                    Notification myplat = item;
                    if (item.getType().ToString().Equals(type))
                        mylist.Add(item);
                }
            }
            return mylist;
        }


        public Plat getPlat(List<Plat> plat)
        {
            GestionPlat managerplat = new GestionPlat();
            return managerplat.Chercher(plat[0].Id);
        }

        public Table getTablebyTable(Commande command)
        {
            GestionTable table = new GestionTable();
            return table.Lister(command)[0];
        }

        public int getNbNotif(string mail)
        {
            GestionNotification test = new GestionNotification();
            return test.Lister(mail, false).Count;
        }

    }
}
